﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SW2A311_Lib;

namespace Server
{
    /// <summary>
    /// Klassen som håndterer server GUI'en
    /// </summary>
    /// <remarks>
    /// Windows forms GUI
    /// </remarks>
    public partial class Form1 : Form
    {
        /// <summary>
        /// Delegate til at håndtere chatbeskeder
        /// </summary>
        public ChatMessageToTextbox DelegateChatMessage;
        /// <summary>
        /// Constructor til at instantiere formen
        /// </summary>
        /// <remarks>
        /// Kører autogenereret kode samt sørger for chatbeskeder kommer op i tekstboxen på serveren
        /// </remarks>
        public Form1()
        {
            InitializeComponent();
            DelegateChatMessage = new ChatMessageToTextbox(AppendChatMessageToTextbox);

        }
        /// <summary>
        /// Delegate der håndterer chatbeskeder
        /// </summary>
        /// <param name="Message"></param>
        public delegate void ChatMessageToTextbox(object Message);
        private void AppendChatMessageToTextbox(object Message)
        {
            EventDrivenShare.ChatMessageArgs ChatMessage = (EventDrivenShare.ChatMessageArgs)Message;
            InfoBox.AppendText(ChatMessage.ChatMessage);
            InfoBox.AppendText("\n");
        }
    }
}
